﻿<!DOCTYPE>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=EDGE;IE=11;IE=8,chrome=1" />
    <title>工步主辅材准备清单</title>
    <link href="/InSiteWebApplication/Content/Easyui/themes/metro/easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/custom-easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/themes/icon.css" rel="stylesheet" />
</head>
<body>
    <div id="mainSec">
        <div class="panelSection">
            <div class="easyui-panel " title="搜索区域" style="padding: 3px; width: 100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false">
                <form id="queryForm" action="">
                <div style="margin: 3px 0px 3px 3px">
                    <div style="float: left">
                        <div class="divLabel" style="margin-bottom: 5px;">
                            主制分厂：</div>
                        <select id="txtMainFactoryID" class="easyui-combobox" name="MainFactoryID" data-options=""
                            style="width: 150px; height: 22px">
                        </select>
                    </div>
                    <div style="float: left; margin-left: 10px">
                        <div class="divLabel" style="margin-bottom: 5px">
                            订单号：</div>
                        <input id="txtMfgOrderName" class="easyui-textbox" name="MfgOrderName" data-options=""
                            style="width: 120px; height: 22px" />
                    </div>
                    <div style="float: left; margin-left: 10px">
                        <div class="divLabel" style="margin-bottom: 5px">
                            件号：</div>
                        <input id="txtProductName" class="easyui-textbox" name="ProductName" data-options=""
                            style="width: 120px; height: 22px" />
                    </div>
                    <div style="float: left; margin-left: 10px">
                        <div class="divLabel" style="margin-bottom: 5px">
                            批次号：</div>
                        <input id="txtContainerName" class="easyui-textbox" name="ContainerName" data-options=""
                            style="width: 120px; height: 22px" />
                    </div>
                    <div style="float: left; margin-left: 10px">
                        <div class="divLabel" style="margin-bottom: 5px">
                            工步号：</div>
                        <input id="txtStepInfoNo" class="easyui-textbox" name="StepInfoNo" data-options="" style="width: 120px;
                            height: 22px" />
                    </div>
                    <div style="float: left; margin-left: 10px">
                        <div class="divLabel" style="margin-bottom: 5px">
                            排产计划日期：</div>
                        <input id="txtApsPlanStartDate1" class="easyui-textbox" name="ApsPlanStartDate1" type="text" data-options=""
                            style="width: 120px; height: 22px" />
                        <input id="txtApsPlanStartDate2" class="easyui-textbox" name="ApsPlanStartDate2" type="text" data-options=""
                            style="width: 120px; height: 22px" />
                    </div>
                    <div style="float: left; margin-left: 20px">
                        <a href="#" id="btnSearch" class="easyui-linkbutton" data-options="" style="margin-top: 16px;
                            width: 80px">查询</a>
                    </div>
                    <div style="float: left; margin-left: 10px">
                        <a href="#" id="btnReset" class="easyui-linkbutton" data-options="" style="margin-top: 16px;">
                            重置</a>
                    </div>
                    <div style="clear: both">
                    </div>
                </div>
                </form>
            </div>
        </div>
        <div class="panelSection">
            <div class="easyui-panel " title="结果列表" style="padding: 3px; width: 100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false">
                <div>
                    <button id="btnExport" class="easyui-linkbutton" type="button" style="height: 24px;
                        margin-left: 10px">
                        导出</button>
                </div>
                <div class="dvgrid-cellwarp" style="margin-top: 3px">
                    <table id="gdResult" class="easyui-datagrid" style="width: 100%; height: 350px" data-options="rownumbers:true,fitColumns:true,pageNumber:1,pageSize:5,pageList:[10,20,50,100]">
                    </table>
                    <div id="pp" style="float: right" class="easyui-pagination" data-options="   
                 layout:['first','prev','next','last','manual','info'],              
                    total: 0,
                    showPageList: false,
                    showPageInfo: false,
                    showRefresh: false,
                    afterPageText:'共&nbsp{pages}&nbsp页',
                     buttons:[{
                            iconCls:'',
                            text:'Go',
                            group:'paging-tail-btns',
                            id:'pageGo'
                    }]
                ">
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/ReferenceJsLib.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.easyui.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script type="text/javascript" src="/InSiteWebApplication/Content/Easyui/datagrid-groupview.js"></script>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/CustomCommon.js" type="text/javascript"></script>
<script type="text/javascript">
    /*
    创建人：zhangrj
    日期：2024-08-09
    描述：工步主辅材准备清单JS
    */
    var page = {
        pageTotal: 0,
        pageSize: 20,
        pageNumber: 1,
        rootPath: getRootPath(), //网站根路径
        url: getRootPath() + "/Ashx/ApsHandler/RbApsLimitedCapacityHandler.ashx",
        commonUrl: getRootPath() + "/Ashx/CommonHandler.ashx",
        //初始化页面
        init: function () {
            page.bind();
            customizedEasyuiPagination('pp'); //定制化分页
        },
        //页面事件绑定
        bind: function () {
            //列表加载
            $("#gdResult").datagrid({
                onLoadSuccess: function (data) {
                    $('#pp').pagination('refresh', {	// 改变选项，并刷新分页栏信息
                        total: page.pageTotal,
                        pageSize: page.pageSize,
                        pageNumber: page.pageNumber
                    });
                    customizedEasyuiPagination('pp'); //定制化分页
                },
                columns: [[
                 { field: 'ck', title: '选择', checkbox: true },
                 { field: 'MFGORDERNAME', title: '订单号', width: 120 },
                 { field: 'CONTAINERNAME', title: '批次号', width: 200 },
                 { field: 'FACONTAINERNAME', title: '主制批次', width: 200 },
                 { field: 'WORKFLOWINFO', title: '工艺信息', width: 200 },
                 { field: 'CONTAINERQTY', title: '在制数', width: 80 },
                 { field: 'STEPNO', title: '工步号', width: 80 },
                 { field: 'STEPINFODESC', title: '工步名', width: 120 },
                 { field: 'STARTTIME', title: '计划开始日期', width: 120 },
                 { field: 'ENDTIME', title: '计划结束日期', width: 120 },
                 { field: 'AUXMATERIALNAME', title: '辅材编号', width: 100 },
                 { field: 'AUXMATERIALDESC', title: '辅材名', width: 100 },
                 { field: 'NEEDQTY', title: '需求数量', width: 80 },
                 { field: '', title: '库存数量', width: 80 }
                ]]
            });
            //查询按钮
            $('#btnSearch').on("click", function () {
                page.clearPage(false, true);
                page.pageNumber = 1;
                page.searchData();
            });
            //导出按钮
            $('#btnExport').on("click", function () {
                page.openDialog(false);
            });
            //分页事件
            $('#pp').pagination({
                onSelectPage: function (pageNumber, pageSize) {
                    //                customizedEasyuiPagination('pp'); //定制化分页
                    page.pageSize = pageSize; page.pageNumber = pageNumber === 0 ? 1 : pageNumber;
                    page.searchData();
                }
            });
            //绑定分页go按钮
            $('#pageGo').on("click", function () {
                var pageNumber = Number($(this).parents('tr').find('.pagination-num').val());
                page.pageSize = $(".pagination-page-list").val();
                page.pageNumber = pageNumber;
                page.searchData();
            });
            //清除按钮
            $('#btnReset').on("click", function () {
                page.clearPage(true, true);
                page.pageNumber = 1; page.pageTotal = 0
                $('#pp').pagination('refresh', {
                    total: page.pageTotal,
                    pageSize: page.pageSize,
                    pageNumber: page.pageNumber
                });
            });
        },
        //查询
        searchData: function () {
            var params = {
                pageSize: page.pageSize,
                pageIndex: page.pageNumber
            };
            var queryFormData = $("#queryForm").serializeArray();
            $.each(queryFormData, function () {
                params[this.name] = this.value;
            });
            page.post(page.url, { action: "GetMaterialProductPrepareData", params: JOSN.stringify(params) }, true, function (res) {
                if (!res.Result) {
                    displayMessage(res.Message, res.Result);
                    return;
                }
                page.pageTotal = res.RowCount;
                $("#gdResult").datagrid('loadData', { total: res.RowCount, rows: res.DBTable });
            });
        },
        //导出数据
        exportData: function () {
            var params = {};
            var queryFormData = $("#queryForm").serializeArray();
            $.each(queryFormData, function () {
                params[this.name] = this.value;
            });
            FileDownLoad(page.url, { action: "ExportMaterialProductPrepareData", params: JSON.stringify(params) });
        },
        //禁用页面按钮
        disableBtn: function () {
            $("#mainSec").find(".easyui-linkbutton").each(function () {
                $(this).linkbutton('disable');
            });
        },
        //启用页面按钮
        enableBtn: function () {
            $("#mainSec").find(".easyui-linkbutton").each(function () {
                $(this).linkbutton('enable');
            });
        },
        //清除页面（查询区域，列表区域）
        clearPage: function (query, list) {
            if (query) {
                $("#txtMainFactoryID").combobox("clear");
                $("#txtApsPlanStartDate1").datebox("clear");
                $("#txtApsPlanStartDate2").datebox("clear");
                $("#txtProductName").textbox("clear");
                $("#txtContainerName").textbox("clear");
                $("#txtMfgOrderName").textbox("clear");
                $("#txtStepInfoNo").textbox("clear");
            }
            if (list) {
                clearEasyuiDataGrid("gdResult"); //清空列表
            }
        },
        //post数据（路径，参数，是否异步，成功返回方法）
        post: function (url, param, async, callback) {
            $.ajax({
                type: "Post",
                url: url,
                data: param,
                cashe: false,
                async: async,
                dataType: "json",
                beforeSend: function () {
                    $.messager.progress({ text: '', msg: '处理中...' });
                },
                success: function (data) {
                    $.messager.progress('close');
                    callback(data);
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $.messager.progress('close');
                    displayMessage(XMLHttpRequest.responseText, false);
                    $("body").find(".easyui-linkbutton").each(function () {
                        $(this).linkbutton('enable');
                    });
                }
            });
        }
    };
    $(function () {
        page.init();
    });
</script>
